package yz.mr.ReduceJoin;

import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class ReduceJoinReduce extends Reducer<Text,Text,Text,Text> {
    /**
     * @param key  这里的key是学生id
     * @param values 这里的value是学生的一些信息
     * @param context
     * @throws IOException
     * @throws InterruptedException
     */
    @Override
    protected void reduce(Text key, Iterable<Text> values, Reducer<Text, Text, Text, Text>.Context context) throws IOException, InterruptedException {
        String otherInfo = "";
        String score = "";
        for (Text value : values) {
            String info = value.toString();
            //解下来对其他信息进行分析
            if (info.contains(",")){
                otherInfo=info;
            }
            else {
                score=info;
            }
        }
        context.write(key,new Text(otherInfo+","+score));
    }
}
